package com.wxhandle.cleandemo.api.security;

import java.lang.reflect.Method;

import org.springframework.cglib.proxy.MethodInterceptor;
import org.springframework.cglib.proxy.MethodProxy;
import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
import org.springframework.security.access.method.MethodSecurityMetadataSource;

import net.bytebuddy.implementation.bytecode.member.MethodInvocation;

public class DefaultMethodSecurityInterceptor extends AbstractSecurityInterceptor implements
MethodInterceptor {

    private MethodSecurityMetadataSource securityMetadataSource;

    @Override
    public Object intercept(Object arg0, Method arg1, Object[] arg2, MethodProxy arg3) throws Throwable {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Class<?> getSecureObjectClass() {
        return MethodInvocation.class;
    }

    @Override
    public SecurityMetadataSource obtainSecurityMetadataSource() {
        if(this.securityMetadataSource == null)
            this.securityMetadataSource = new DefaultMethodSecurityMetadataSource();
        return this.securityMetadataSource;
    }
    
}
